tests: Add a patternspec argument for test creation
authorBenjamin Otte <otte@redhat.com>
Mon, 26 Dec 2016 16:08:06 +0000 (17:08 +0100)
committerBenjamin Otte <otte@redhat.com>
Mon, 26 Dec 2016 16:22:01 +0000 (17:22 +0100)
That way, I don't need to recreate all the tests I don't care about.

This is particularly useful when I want to change the size of the
testcase.

tests/rendernode-create-tests.c

index 06519ce3823bf3f6e3ae7156f9f86684b24bad1b..b2d75f15c720787b858d27c8d86000965d2dab43 100644 (file)
@@ -237,17 +237,29 @@ main (int argc, char **argv)
   };
   GError *error = NULL;
   GskRenderNode *node;
+  GPatternSpec *matcher;
+  char *pattern;
   guint i, n;
 
   gtk_init (&argc, &argv);
 
+  n = 100000;
+  pattern = "*";
+
   if (argc > 1)
-    n = atoi (argv[1]);
-  else
-    n = 100000;
+    {
+      if (argc > 2)
+        pattern = argv[2];
+      n = atoi (argv[1]);
+    }
+
+  matcher = g_pattern_spec_new (pattern);
 
   for (i = 0; i < G_N_ELEMENTS (functions); i++)
     {
+      if (!g_pattern_match_string (matcher, functions[i].name))
+        continue;
+
       node = functions[i].func (n);
       if (!gsk_render_node_write_to_file (node, functions[i].name, &error))
         {
@@ -259,5 +271,7 @@ main (int argc, char **argv)
       g_print ("Created test file \"%s\".\n", functions[i].name);
     }
 
+  g_pattern_spec_free (matcher);
+
   return 0;
 }